import type { FormList, SearchList } from "@/types/form";
import type { TableColumn, TableOptions } from "@/types/public";
import { FORM_REQUIRED, MENU_ACTIONS } from "@/utils/config";
import { MENU_MODULE } from "@/utils/constants";

// 搜索数据
export const searchList = (): SearchList[] => [
    {
        label: "订单编号",
        name: "name",
        wrapperWidth: 200,
        component: "Input",
    },
    {
        label: "日期",
        name: "pay_date",
        component: "RangePicker",
        componentProps: {
            allowClear: true,
        },
    },
    {
        label: "船名",
        name: "module1",
        wrapperWidth: 200,
        component: "Select",
        componentProps: {
            options: MENU_MODULE(),
        },
    },
    {
        label: "订单状态",
        name: "module2",
        wrapperWidth: 200,
        component: "Select",
        componentProps: {
            options: MENU_MODULE(),
        },
    },
];

/**
 * 表格数据
 * @param optionRender - 渲染操作函数
 */
export const tableColumns = (optionRender: TableOptions<object>): TableColumn[] => {
    return [
        {
            title: "ID",
            dataIndex: "id",
            width: 100,
        },
        {
            title: "订单编号",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "货物名称",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "站点",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "货代公司",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "船名",
            dataIndex: "username",
            width: 150,
        },
        {
            title: "录入用户",
            dataIndex: "content",
            width: 150,
        },

        {
            title: "添加日期",
            dataIndex: "content",
            width: 150,
        },
        {
            title: "状态",
            dataIndex: "content",
            width: 150,
        },
        {
            title: "是否提交",
            dataIndex: "content",
            width: 150,
        },
        {
            title: "是否混装",
            dataIndex: "content",
            width: 150,
        },
        {
            title: "操作",
            dataIndex: "operate",
            width: 100,
            render: (value: unknown, record: object) => optionRender(value, record),
        },
    ];
};

// 新增数据
export const createList = (): FormList[] => [
    {
        label: "轮船编号",
        name: "username1",
        rules: FORM_REQUIRED,
        component: "Input",
    },
    {
        label: "品种",
        name: "username2",
        rules: FORM_REQUIRED,
        component: "Input",
    },
    {
        label: "站点",
        name: "username3",
        component: "Input",
    },
    {
        label: "货代公司",
        name: "username4",
        component: "Input",
    },
    {
        label: "船名",
        name: "username5",
        component: "Input",
    },
    {
        label: "混装",
        name: "actions",
        component: "CheckboxGroup",
        componentProps: {
            options: MENU_ACTIONS(),
        },
    },
    {
        label: "状态",
        name: "real_name",
        rules: FORM_REQUIRED,
        component: "Select",
        componentProps: {
            options: MENU_MODULE(),
        },
    },
];
